<?php
require_once("../../class2.php");
require_once(HEADERF);
		$user_id = USERID;
		$user_name = USERNAME;
require_once("./includes/require_all.php");

?>

<script language="javascript" type="text/javascript">
<!-- 
//Browser Support Code
function ajaxFunction(named, game, name, status){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.myForm.time.value = ajaxRequest.responseText;
		}
	}
	
	var trans = document.getElementById(named).value;
	ajaxRequest.open("GET", "http://playonbg.info/translations/cms/dict_exec.php?game="+game+"&name="+name+"&trans="+trans+"&status="+status, true);
	ajaxRequest.send(null); 
}

//-->
</script>

<?php

ramka("open");

if (in_array($user_name, $mods)) {

	echo "<a href='http://playonbg.info/translations/' class='forumheader4' style='font-size:14px; margin-left:10px;'>НАЗАД</a><br>";
	echo "<center class='forumheader4' style='margin-top:-20px; margin-left:-1px; padding-bottom:6px;'><h1 style='border-bottom:0px;'>Речник</h1></center>";
	echo "<div class='forumheader4'><span style='color:green'>Легенда: </span>
					<span class='dictGREEN'>✔</span> одобрена дума;
					<span class='dictYELLOW'>⚠</span> чакаща одобрение;
					<span class='dictRED'>✘</span> изтриване.<br><br>";

	CMS_activitySave("dict.php");

	if (isset($_GET['game'])){
		$chosen_query= "SELECT * FROM cms_dict WHERE (status='0' OR status='1') AND game='$_GET[game]'";
	} else $chosen_query= "SELECT * FROM cms_dict WHERE status='0' OR status='1'";
	
	$dictionary= mysql_query($chosen_query);
	while ($word= mysql_fetch_array($dictionary)) {
		$dictarray[$word['game']][$word['keyword']]['translation']= $word['translation'];
		$dictarray[$word['game']][$word['keyword']]['status']= $word['status'];
	}

	if(isset($dictarray)){
		foreach ($dictarray as $game=>$wordlist) { $num=0;
			echo "<h2 id='$game' class='forumheader dictWHITE' style='padding:5px;'>$game</h2>";
			echo "<table style='float:left' width=99% CELLSPACING='0' CELLPADDING ='1'>";
			foreach ($wordlist as $keyword=>$set) {
				if($num%2==1) { $classRow= "cmsRow1"; }
				else { $classRow= "cmsRow2"; }
				$num++;
				if($set['status']==0) {
					$classY= "dictGREY";
					$classX= "dictYELLOW";
					$classY2= "dictGREEN";
					$classX2= "dictGREY";			
					}
				elseif($set['status']==1) {
					$classY= "dictGREEN";
					$classX= "dictGREY";
					$classY2= "dictGREY";
					$classX2= "dictYELLOW";
					}
				$translation= $set['translation'];
				$keywordsl= addslashes($keyword);
				$translation= str_replace("\"", "&quot;", $translation);
				echo <<<HTML
							<tr class="forumheader3">
							<td width="3%"></td>
							<td width="3%">✎</td>
							<td width="20%" class="dictYELLOW">$keyword </td>
							<td width="55%"><input type="text" class="tbox" size=70 name="$game$keyword" value="$translation" id="$game$keyword"\></td>
							<td width="15%">
								<center>
								<button type="button" id="but1_$game$keyword" class="dictButton hoverGREEN $classY" style="display:inline;" onClick="ajaxFunction('$game$keywordsl', '$game', '$keywordsl', '1'); changeClass('but1_$game$keywordsl', 'dictButton hoverGREEN dictGREEN'); changeClass('but2_$game$keywordsl', 'dictButton hoverYELLOW dictGREY');">✔</button>
								<button type="button" id="but2_$game$keyword" class="dictButton hoverYELLOW $classX" style="display:inline;" onClick="ajaxFunction('$game$keywordsl', '$game', '$keywordsl', '0'); changeClass('but1_$game$keywordsl', 'dictButton hoverGREEN dictGREY'); changeClass('but2_$game$keywordsl', 'dictButton hoverYELLOW dictYELLOW');">⚠</button>
								<button type="button" id="but3_$game$keyword" class="dictButton hoverRED dictGREY" style="display:inline;" onClick="ajaxFunction('$game$keywordsl', '$game', '$keywordsl', '2'); changeClass('but1_$game$keywordsl', 'dictButton hoverGREEN dictGREY'); changeClass('but2_$game$keywordsl', 'dictButton hoverYELLOW dictGREY'); changeClass('but3_$game$keywordsl', 'dictButton hoverRED dictRED');">✘</button>
								</center>
							</td>
							</tr>
HTML;
				}
			echo "</table><br style='clear:left'><br>";
		}
	} 
	echo "</div>";
}
else echo "<meta http-equiv=\"refresh\" content=\"0;http://playonbg.info\" />";

ramka("close");

require_once(FOOTERF);
?>